package com.bwf.lgqingdan.gui.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bwf.lgqingdan.R;
import com.bwf.lgqingdan.entity.ResponseAllTags;
import com.bwf.lgqingdan.gui.adapter.base.BaseRecycleViewAdapter;
import com.facebook.drawee.view.SimpleDraweeView;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2016/11/19.
 */

public class AllTagsAdapter extends BaseRecycleViewAdapter<ResponseAllTags.DataBean.TagsBean> {
    public AllTagsAdapter(Context context) {
        super(context);
    }

    @Override
    protected int getHeaderItemCount() {
        return 0;
    }

    @Override
    protected int getFooterItemCount() {
        return 0;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = inflaterView(R.layout.list_item_all_tags, parent);
        return new ItemViewHolder(view);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        ItemViewHolder viewHolder = (ItemViewHolder) holder;
        ResponseAllTags.DataBean.TagsBean bean = getItem(position);
        String imgUrl = "";
       try{//可能没有图片
           imgUrl = bean.getCoverImage().getThumbnail().getImageUrl();
       }catch (Exception e){

       }
        viewHolder.imgItemCoverAllTags.setImageURI(imgUrl);
        viewHolder.tvItemTitleAllTags.setText(bean.getName());
        viewHolder.tvItemDescAllTags.setText(bean.getExcerpt());
        viewHolder.tvItemArticleAllTags.setText(bean.getArticleCount()+"");
        viewHolder.tvItemThingsAllTags.setText(bean.getThingCount()+"");
    }

     class ItemViewHolder extends BaseViewHolder{
        @BindView(R.id.img_item_cover_all_tags)
        SimpleDraweeView imgItemCoverAllTags;
        @BindView(R.id.tv_item_title_all_tags)
        TextView tvItemTitleAllTags;
        @BindView(R.id.tv_item_desc_all_tags)
        TextView tvItemDescAllTags;
        @BindView(R.id.tv_item_article_all_tags)
        TextView tvItemArticleAllTags;
        @BindView(R.id.tv_item_things_all_tags)
        TextView tvItemThingsAllTags;

         ItemViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
